from rest_framework import serializers
from .models import WeiboModel, CommentModel, UserUpload
from django_filters import rest_framework as filters


class WeiboDataSerializer(serializers.ModelSerializer):
    """
    电影数据序列化器
    """

    class Meta:
        model = WeiboModel
        exclude = ["id"]


class CommentDataSerializer(serializers.ModelSerializer):
    """
    Top 电影数据序列化器
    """

    class Meta:
        model = CommentModel
        exclude = ["id"]


class WeiboFilter(filters.FilterSet):
    text = filters.CharFilter(field_name="text", lookup_expr='icontains')
    flag = filters.CharFilter(field_name="flag")

    class Meta:
        model = WeiboModel
        fields = ['text', 'flag']


class CommentFilter(filters.FilterSet):
    text = filters.CharFilter(field_name="content", lookup_expr='icontains')

    class Meta:
        model = CommentModel
        fields = ['text']


class UserUploadSerializers(serializers.ModelSerializer):
    """
    用户文件上传序列化器
    """

    class Meta:
        model = UserUpload
        fields = '__all__'
